. use "G:\Mi unidad\Alvacast\SISTRAT 2019 (github)\Stata SER 2020\_CONS_C1_df_csv_pedido_SER2020_avance
> 6(ENE 2020).dta", clear

Presentation of SER 2020

27 Jan 2020

The following indices are preliminary results to be presented on SER 2020. We used a dataset in construction, in which many cases had to be discarded in order to produce valid estimates. However, we are still working to rescue as much valid treatments and patients as possible.

This survival setting selected the first events from each HASH, The event is defined by being readmitted one or more times between 2010 to 2019.

Person days are concieved as the difference in each HASH, of the minimum date of admission (the first time that each patient was admitted between 2010 and 2019), and the maximum date of discharge (the last time that a patient was discharged from a treatment between 2010 and 2019).

. gen a_botar=.
(103,669 missing values generated)

. *cases with only one event are  keeped
. * dup= count how many times the hash has repeated (eg. 1, 2,  3)
. * duplicates_filtered= count the total times each hash has repeated, different than duplicated_hash b
> ecause this may be considering deleted cases. 
. *get the first case if there are no other among them
. recode a_botar .=1 if dup==0 & duplicates_filtered==1
(a_botar: 58752 changes made)

. *always get the first treatment, if it has more than one: 
. *get the first case if there are no other among them
. recode a_botar .=1 if dup==1 & duplicates_filtered>1
(a_botar: 17832 changes made)

. *codebook hash_key if dup==1 & duplicates_filtered>1 == 17,832
. ******browse hash_key a_botar dup duplicates_filtered if dup==0 & duplicates_filtered ==1
. ******browse hash_key a_botar dup duplicates_filtered if duplicates_filtered >1
. ****drop unique cases
. drop if missing(a_botar)
(27,085 observations deleted)

. ****generate event if each hash has more than one admission
. gen event=0

. recode event 0=1 if dup>0
(event: 17832 changes made)

Then, we set the dataset as a survival time format, configured by years (365.25 days) and defined by the difference between the last date of discharge of the last treatment and the date of admission of the following treatment (person_days) along the datasets from 2010 to 2019.

. stset person_days, failure(event==1) scale(365.25) id(row)

                id:  row
     failure event:  event == 1
obs. time interval:  (person_days[_n-1], person_days]
 exit on or before:  failure
    t for analysis:  time/365.25

──────────────────────────────────────────────────────────────────────────────
     76,584  total observations
          0  exclusions
──────────────────────────────────────────────────────────────────────────────
     76,584  observations remaining, representing
     76,584  subjects
     17,832  failures in single-failure-per-subject data
 89,802.045  total analysis time at risk and under observation
                                                at risk from t =         0
                                     earliest observed entry t =         0
                                          last observed exit t =  11.91239

. stdescribe, weight

         failure _d:  event == 1
   analysis time _t:  person_days/365.25
                 id:  row

                                   ├────────────── per subject ──────────────┤
Category                   total        mean         min     median        max
──────────────────────────────────────────────────────────────────────────────
no. of subjects            76584   
no. of records             76584           1           1          1          1

(first) entry time                         0           0          0          0
(final) exit time                   1.172595    .0027379   .6105407   11.91239

subjects with gap              0   
time on gap if gap             0           .           .          .          .
time at risk           89802.045    1.172595    .0027379   .6105407   11.91239

failures                   17832    .2328424           0          0          1
──────────────────────────────────────────────────────────────────────────────

Of the 76584 subjects, 17832 had more than one treatment.

. stsum

         failure _d:  event == 1
   analysis time _t:  person_days/365.25
                 id:  row

         │               incidence       no. of    ├────── Survival time ─────┤
         │ time at risk     rate        subjects        25%       50%       75%
─────────┼─────────────────────────────────────────────────────────────────────
   total │  89802.04517   .1985701         76584   1.820671  3.017112   4.76386

We calculated the failures in single-failre-per-subject data, divided by the total analysis time at risk and under observation. The cumulative incidence rate of readmission was 198.6 (per 1,000 patients/year).

Incidence Rate By Groups

We recoded the variables of cause of discharge, in order to account for early drop-out and late drop-out.

. recode motivodeegreso     (1=.  ) ///
>                     (2=3  "Alta Administrativa") ///
>                     (3=4 "Alta Terap�utica") ///
>                     (4=5 "Derivaci�n"), gen(mot_egreso_rec)
(76583 differences between motivodeegreso and mot_egreso_rec)

. recode mot_egreso_rec .=1 if earlywdl==1
(mot_egreso_rec: 12766 changes made)

. recode mot_egreso_rec .=2 if earlywdl==0
(mot_egreso_rec: 27783 changes made)

. 
. label define mot_egreso_rec 1 "Abandono Temprano", modify

. label define mot_egreso_rec 2 "Abandono Tardio", modify

. 
. recode mot_egreso_rec    (4=0 "Alta Terap�utica") ///
>                     (1=1 "Abandono Temprano") (else=.), gen(mot_egres_earlywdl)
(63715 differences between mot_egreso_rec and mot_egres_earlywdl)

. tab mot_egreso_rec mot_egres_earlywdl, miss

                    │ RECODE of mot_egreso_rec (RECODE
          RECODE of │        of motivodeegreso)
     motivodeegreso │ Alta Tera  Abandono           . │     Total
────────────────────┼─────────────────────────────────┼──────────
  Abandono Temprano │         0     12,766          0 │    12,766 
    Abandono Tardio │         0          0     27,783 │    27,783 
Alta Administrativa │         0          0      6,839 │     6,839 
   Alta Terap�utica │    17,552          0          0 │    17,552 
         Derivaci�n │         0          0     11,541 │    11,541 
                  . │         0          0        103 │       103 
────────────────────┼─────────────────────────────────┼──────────
              Total │    17,552     12,766     46,266 │    76,584 

. 
. recode mot_egreso_rec    (4=0 "Alta Terap�utica") ///
>                     (2=1 "Abandono Tard�o") (else=.), gen(mot_egres_latewdl)
(76481 differences between mot_egreso_rec and mot_egres_latewdl)

. tab mot_egreso_rec mot_egres_latewdl, miss

                    │ RECODE of mot_egreso_rec (RECODE
          RECODE of │        of motivodeegreso)
     motivodeegreso │ Alta Tera  Abandono           . │     Total
────────────────────┼─────────────────────────────────┼──────────
  Abandono Temprano │         0          0     12,766 │    12,766 
    Abandono Tardio │         0     27,783          0 │    27,783 
Alta Administrativa │         0          0      6,839 │     6,839 
   Alta Terap�utica │    17,552          0          0 │    17,552 
         Derivaci�n │         0          0     11,541 │    11,541 
                  . │         0          0        103 │       103 
────────────────────┼─────────────────────────────────┼──────────
              Total │    17,552     27,783     31,249 │    76,584 
. ir event mot_egres_earlywdl _t

                 │ RECODE of              │
                 │ mot_egreso_rec [RECODE │
                 │ of motivodeegreso]     │
                 │   Exposed   Unexposed  │      Total
─────────────────┼────────────────────────┼────────────
           event │      2525        2613  │       5138
analysis time wh │  8585.421    25288.66  │   33874.08
─────────────────┼────────────────────────┼────────────
                 │                        │
  Incidence rate │  .2941032    .1033269  │   .1516794
                 │                        │
                 │      Point estimate    │    [95% Conf. Interval]
                 ├────────────────────────┼────────────────────────
 Inc. rate diff. │         .1907763       │      .17864    .2029126 
 Inc. rate ratio │         2.846336       │    2.693769    3.007506 (exact)
 Attr. frac. ex. │         .6486712       │    .6287729    .6674985 (exact)
 Attr. frac. pop │         .3187806       │
                 └────────────────────────┴────────────────────────
                     (midp)   Pr(k>=2525) =                  0.0000 (exact)
                     (midp) 2*Pr(k>=2525) =                  0.0000 (exact)

Compared with those with therapeutic discharge, it was 2.85 [IC95% 2.69- 3.01] times higher among people with early drop-out,

. ir event mot_egres_latewdl _t

                 │ RECODE of              │
                 │ mot_egreso_rec [RECODE │
                 │ of motivodeegreso]     │
                 │   Exposed   Unexposed  │      Total
─────────────────┼────────────────────────┼────────────
           event │      5699        2613  │       8312
analysis time wh │  32030.73    25288.66  │   57319.39
─────────────────┼────────────────────────┼────────────
                 │                        │
  Incidence rate │  .1779229    .1033269  │    .145012
                 │                        │
                 │      Point estimate    │    [95% Conf. Interval]
                 ├────────────────────────┼────────────────────────
 Inc. rate diff. │          .074596       │    .0685104    .0806815 
 Inc. rate ratio │         1.721941       │     1.64373    1.804237 (exact)
 Attr. frac. ex. │           .41926       │    .3916274     .445749 (exact)
 Attr. frac. pop │         .2874594       │
                 └────────────────────────┴────────────────────────
                     (midp)   Pr(k>=5699) =                  0.0000 (exact)
                     (midp) 2*Pr(k>=5699) =                  0.0000 (exact)

Compared with those with therapeutic discharge, it was 1.72 [IC95% 1.64- 1.80] higher among people with late drop-out.

We recoded the variables of main type of drug, in order to account for the main substance and comparisons between them: Cocaine vs. Alcohol, Cocaine Paste vs. Alcohol, and Marihuana vs. Alcohol.

. recode droga (1=1  "Cocaina") ///
>          (2=2  "Alcohol") ///
>          (3=3 "Marihuana") ///
>          (7=4 "Pasta Base") ///
>          (4 5 6 8 9 10=5 "Otros"), gen(droga_rec)
(31980 differences between droga and droga_rec)

. 
. recode droga (1=1  "Cocaina") ///
>          (2=0 "Alcohol" ) ///
>          (3=. ) ///
>          (7=. ) ///
>          (4 5 6 8 9 10=. ), gen(droga_rec_coc)
(62198 differences between droga and droga_rec_coc)

. recode droga (1=.  ) ///
>          (2=0  "Alcohol") ///
>          (3=. ) ///
>          (7=1 "Pasta Base") ///
>          (4 5 6 8 9 10=. ), gen(droga_rec_pbase)
(76584 differences between droga and droga_rec_pbase)

. recode droga (1=.  ) ///
>          (2=0 "Alcohol") ///
>          (3=1 "Marihuana") ///
>          (7=. ) ///
>          (4 5 6 8 9 10=. ), gen(droga_rec_mar)
(76584 differences between droga and droga_rec_mar)
. ir event droga_rec_coc _t

                 │ RECODE of droga [RECODE│
                 │ of drog1               │
                 │ [Sustancia.Principal]] │
                 │   Exposed   Unexposed  │      Total
─────────────────┼────────────────────────┼────────────
           event │      3184        4194  │       7378
analysis time wh │  16009.23    26974.66  │   42983.89
─────────────────┼────────────────────────┼────────────
                 │                        │
  Incidence rate │  .1988853    .1554793  │   .1716457
                 │                        │
                 │      Point estimate    │    [95% Conf. Interval]
                 ├────────────────────────┼────────────────────────
 Inc. rate diff. │          .043406       │    .0350475    .0517645 
 Inc. rate ratio │         1.279175       │    1.221198    1.339807 (exact)
 Attr. frac. ex. │         .2182464       │    .1811321    .2536238 (exact)
 Attr. frac. pop │          .094185       │
                 └────────────────────────┴────────────────────────
                     (midp)   Pr(k>=3184) =                  0.0000 (exact)
                     (midp) 2*Pr(k>=3184) =                  0.0000 (exact)

Compared with those with alcohol as the main substance at admission, the cumulative incidence rate of readmission was 1.28 [IC95% 1.22- 1.34] times higher for those using cocaine.

. ir event droga_rec_pbase _t

                 │ RECODE of droga [RECODE│
                 │ of drog1               │
                 │ [Sustancia.Principal]] │
                 │   Exposed   Unexposed  │      Total
─────────────────┼────────────────────────┼────────────
           event │      9192        4194  │      13386
analysis time wh │  38729.46    26974.66  │   65704.11
─────────────────┼────────────────────────┼────────────
                 │                        │
  Incidence rate │  .2373387    .1554793  │   .2037315
                 │                        │
                 │      Point estimate    │    [95% Conf. Interval]
                 ├────────────────────────┼────────────────────────
 Inc. rate diff. │         .0818595       │    .0751006    .0886183 
 Inc. rate ratio │         1.526497       │    1.471589    1.583653 (exact)
 Attr. frac. ex. │         .3449056       │    .3204624    .3685486 (exact)
 Attr. frac. pop │         .2368424       │
                 └────────────────────────┴────────────────────────
                     (midp)   Pr(k>=9192) =                  0.0000 (exact)
                     (midp) 2*Pr(k>=9192) =                  0.0000 (exact)

Compared with those with alcohol as the main substance at admission, the cumulative incidence rate of readmission was 1.53 [IC95% 1.47- 1.58] times higher for those using cocaine paste.

. ir event droga_rec_mar _t

                 │ RECODE of droga [RECODE│
                 │ of drog1               │
                 │ [Sustancia.Principal]] │
                 │   Exposed   Unexposed  │      Total
─────────────────┼────────────────────────┼────────────
           event │       958        4194  │       5152
analysis time wh │  6007.425    26974.66  │   32982.08
─────────────────┼────────────────────────┼────────────
                 │                        │
  Incidence rate │  .1594693    .1554793  │    .156206
                 │                        │
                 │      Point estimate    │    [95% Conf. Interval]
                 ├────────────────────────┼────────────────────────
 Inc. rate diff. │           .00399       │   -.0071506    .0151307 
 Inc. rate ratio │         1.025663       │    .9551539    1.100506 (exact)
 Attr. frac. ex. │         .0250208       │   -.0469517    .0913269 (exact)
 Attr. frac. pop │         .0046525       │
                 └────────────────────────┴────────────────────────
                     (midp)   Pr(k>=958) =                   0.2390 (exact)
                     (midp) 2*Pr(k>=958) =                   0.4781 (exact)

Compared with those with alcohol as the main substance at admission, there were not important differences in the cumulative incidence for those using marijuana (1.03 [IC95% 0.96- 1.10]).

Incidence Rate Graphics

The following figures shows the Nelson-Aalen for the cumulative hazard of experiencing readmission in the study period.

In order to graphic the differences between Early drop-out and Therapeutic Discharge on a time span, we had to set the dataset in a format that let us capture the first readmission.

. *ytitle("Prob. of Being Readmitted") 
. *"it measures the total amount of risk that has been accumulated up to time t" (p. 8)
. *count data interpretation: "it gives the number of times we would expect (mathematically) to observe
>  failures [or other events] over a given period, if only the failure event were repeatable" (p. 13)
. *https://books.google.de/books?id=xttbn0a-QR8C&printsec=frontcover&hl=de#v=onepage&q&f=false
. sts graph, by (mot_egres_earlywdl) na ci title("Cumulative Hazard to Experience Readmission to" "SUD 
> Treatment, by cause of Discharge") /// 
> subtitle("Nelson-Aalen Estimator w/ Confidence Intervals 95%") ///
> ylabel(#8) ///
> risktable(, size(*.5) order(1 "Therapeutic Discharge" 2 "Early drop-out")) ///
> xtitle("Years Follow-up") xlabel(#8) ///
> note("Source: FONDECYT 1191282, SENDA's SUD Treatments period 2010-2019") ///
> legend(rows(3)) ///
> legend(cols(4)) ///
> graphregion(color(white) lwidth(large)) bgcolor(white) ///
> plotregion(fcolor(white)) graphregion(fcolor(white) ) ///
> legend(order(1 "95% CI Therapeutic Discharge" 2 "Therapeutic Discharge" 3 "95% CI Early drop-out" 4 "
> Early drop-out")size(*.5)region(lstyle(none)) region(c(none)) nobox) 

         failure _d:  event == 1
   analysis time _t:  person_days/365.25
                 id:  row
(note:  named style large not found in class linewidth, default attributes used)
(note:  linewidth not found in scheme, default attributes used)
(note:  named style large not found in class linewidth, default attributes used)
(note:  linewidth not found in scheme, default attributes used)

. graph export "G:\Mi unidad\Alvacast\SISTRAT 2019 (github)\SUD_CL\stata1.svg", as(svg) width(800) heig
> ht(600) replace
(file G:\Mi unidad\Alvacast\SISTRAT 2019 (github)\SUD_CL\stata1.svg written in SVG format)

. 

. sts graph, by (mot_egres_latewdl) na ci title("Cumulative Hazard to Experience Readmission to" "SUD T
> reatment by cause of Discharge") /// 
> subtitle("Nelson-Aalen Estimator w/ Confidence Intervals 95%") ///
> risktable(, size(*.5) order(1 "Therapeutic Discharge" 2 "Late drop-out")) ///
> ylabel(#8) ///
> xtitle("Years Follow-up") xlabel(#8) ///
> note("Source: FONDECYT 1191282, SENDA's SUD Treatments period 2010-2019") ///
> legend(rows(3)) ///
> legend(cols(4)) ///
> graphregion(color(white) lwidth(large)) bgcolor(white) ///
> plotregion(fcolor(white)) graphregion(fcolor(white) ) ///
> legend(order(1 "95% CI Therapeutic Discharge" 2 "Therapeutic Discharge" 3 "95% CI Late drop-out" 4 "L
> ate drop-out")size(*.5)region(lstyle(none)) region(c(none)) nobox) 

         failure _d:  event == 1
   analysis time _t:  person_days/365.25
                 id:  row
(note:  named style large not found in class linewidth, default attributes used)
(note:  linewidth not found in scheme, default attributes used)
(note:  named style large not found in class linewidth, default attributes used)
(note:  linewidth not found in scheme, default attributes used)

. graph export "G:\Mi unidad\Alvacast\SISTRAT 2019 (github)\SUD_CL\stata2.svg", as(svg) width(800) heig
> ht(600) replace
(file G:\Mi unidad\Alvacast\SISTRAT 2019 (github)\SUD_CL\stata2.svg written in SVG format)

         failure _d:  event == 1
   analysis time _t:  person_days/365.25
                 id:  row
(note:  named style large not found in class linewidth, default attributes used)
(note:  linewidth not found in scheme, default attributes used)
(note:  named style large not found in class linewidth, default attributes used)
(note:  linewidth not found in scheme, default attributes used)

(file G:\Mi unidad\Alvacast\SISTRAT 2019 (github)\SUD_CL\stata3.svg written in SVG format)
         failure _d:  event == 1
   analysis time _t:  person_days/365.25
                 id:  row
(note:  named style large not found in class linewidth, default attributes used)
(note:  linewidth not found in scheme, default attributes used)
(note:  named style large not found in class linewidth, default attributes used)
(note:  linewidth not found in scheme, default attributes used)

(file G:\Mi unidad\Alvacast\SISTRAT 2019 (github)\SUD_CL\stata4.svg written in SVG format)
         failure _d:  event == 1
   analysis time _t:  person_days/365.25
                 id:  row
(note:  named style large not found in class linewidth, default attributes used)
(note:  linewidth not found in scheme, default attributes used)
(note:  named style large not found in class linewidth, default attributes used)
(note:  linewidth not found in scheme, default attributes used)

(file G:\Mi unidad\Alvacast\SISTRAT 2019 (github)\SUD_CL\stata5.svg written in SVG format)

Time outside treatment

. use "G:\Mi unidad\Alvacast\SISTRAT 2019 (github)\Stata SER 2020\_CONS_C1_df_csv_pedido_SER2020_avance
> 6(ENE 2020).dta", clear

To calculate the average time outside treatment, we needed to drop cases with only one treatment and keep those with more than one treatment.

. gen a_botar=.
(103,669 missing values generated)

. recode a_botar .=1 if dup==0 & duplicates_filtered==1
(a_botar: 58752 changes made)

. drop if a_botar==1
(58,752 observations deleted)

Then, we had to order the dataset by HASHs and date of admission and date of discarge, and replace the date of discharge if it is greater than the next date of admission.

. gsort hash_key fech_ing_fmt fech_egres_fmt

. *si la fecha de  egreso es mayor a la siguiente fecha de ingreso, reemplazar con la fecha de ingreso
. by hash_key: gen fech_egres_fmt_corr = fech_ing_fmt[_n+1] if fech_egres_fmt>fech_ing_fmt[_n+1]  
(43,764 missing values generated)

. *si se quiere, replace
. by hash_key: replace fech_egres_fmt = fech_ing_fmt[_n+1] if fech_egres_fmt>fech_ing_fmt[_n+1]  
(1153 real changes made)

. **formatear
. format fech_egres_fmt_corr %td

. format fech_ing_fmt %td

Finally, we get the difference between the most recent date of admission and the next date of discharge (or lagged date). For example, if a patient X had 4 treatments, and among them, in the second treatment he/she was discharged in January 27, and the third treatment was admitted from March 30. Time span will be the 62 days.

. *We iteratively stablished differences between times
. *get the time span between the date of admission and date of discharge
. bysort hash_key (fech_ing_num): gen time5 = fech_egres_fmt - fech_ing_fmt[_n-1]
(17,832 missing values generated)

. *bysort hash_key (fech_ing_num): gen time6  = time5 - time[_n-1]  
. rename time5 span_treat

As can be seen in the following figure, days between treatments among patients tend to group from 0 to 1000 days, but with a sustained decrease starting from 500 days.

. hist span_treat,freq title(Histogram of Treatment Span) xtitle(Days Between Treatments) scheme(s1mono
> )
(bin=44, start=3, width=95.659091)

. graph export "G:\Mi unidad\Alvacast\SISTRAT 2019 (github)\SUD_CL\stata6.png", as(png) width(800) heig
> ht(600) replace
(file G:\Mi unidad\Alvacast\SISTRAT 2019 (github)\SUD_CL\stata6.png written in PNG format)

. drop if missing(span_treat)
(17,832 observations deleted)

. mean(span_treat)

Mean estimation                   Number of obs   =     27,085

─────────────┬────────────────────────────────────────────────
             │       Mean   Std. Err.     [95% Conf. Interval]
─────────────┼────────────────────────────────────────────────
  span_treat │   784.9074    3.73449      777.5876    792.2272
─────────────┴────────────────────────────────────────────────

. mat be= e(b)

>

The average treatment span between treatment was 2.15 years, for every event in the dataset. However. Considering the question was made focusing in those readmitted to treatment, we needed to collapse the dataset by HASHs.

. collapse (mean) avg_span_treat=span_treat, by(hash_key) 

. mean(avg_span_treat)

Mean estimation                     Number of obs   =     17,832

───────────────┬────────────────────────────────────────────────
               │       Mean   Std. Err.     [95% Conf. Interval]
───────────────┼────────────────────────────────────────────────
avg_span_treat │    848.724   4.587316      839.7324    857.7155
───────────────┴────────────────────────────────────────────────

. mat b= e(b)

Summarising by HASHs, the average treatment span between treatments among the readmitted (17832) in years is around 2.32 years.

Go back to the main webpage